const { ccclass, property } = cc._decorator;

@ccclass
export default class PersonalCenterCtrl extends cc.Component {
    @property(cc.Node)
    webNode: cc.Node = null;

    @property(cc.WebView)
    web: cc.WebView = null;

    @property(cc.Node)
    aboutUsNode: cc.Node = null;

    @property(cc.Label)
    label_game_name: cc.Label = null;

    @property(cc.Label)
    label_version: cc.Label = null;

    @property(cc.Label)
    label_app_version: cc.Label = null;

    @property(cc.Label)
    label_channel: cc.Label = null;

    @property(cc.Node)
    personalize_open: cc.Node = null;

    @property(cc.Node)
    personalize_close: cc.Node = null;

    isOpen: boolean = true;

    clickAgreement(e: string, t: string) {
        this.webNode.active = true;
        const a = !c.getInstance().isOnlineRelease();
        const o = t == h.WebUrlType.USER_TYPE ? l.user_url + "&debug=" + a : l.privacy_url;
        o += "&fd=1";
        s.log("webUrl===webUrl", o);
        this.web.url = o;
    }

    closeAgreement() {
        this.webNode.active = false;
    }

    feedback() {
        s.log("客服");
        const e = n.wx_head;
        const t = n.user_name;
        const a = n.wx_gender;
        const userId = n.user_id;
        p.reportData("u_click_kefu");
        p.feedback(t, e, a);
    }

    clickAboutUs() {
        this.aboutUsNode.active = true;
        this.label_game_name.getComponent(cc.Label).string = d.GAME_NAME;
        this.label_version.getComponent(cc.Label).string = "V" + c.getInstance().getVersion();
        this.label_app_version.getComponent(cc.Label).string = u.version_name || "";
        this.label_channel.getComponent(cc.Label).string = u.channel_name || "";
    }

    closeAboutUs() {
        this.aboutUsNode.active = false;
    }

    clickPersonalize() {
        this.isOpen = !this.isOpen;
        this.personalize_open.active = this.isOpen;
        this.personalize_close.active = !this.isOpen;
    }
}
